home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 June / macformat-038.iso / Demos / Interactive Wave / _DATAS / SHARED.Dxr / 00987_gestion du son.ls < prev    next >
Encoding:
Text File  |  1995-08-06  |  6.5 KB  |  270 lines

  1. on SetVolume NiveauVolume
  2.   global MemoVolume
  3.   set the soundLevel to NiveauVolume
  4.   updateStage()
  5.   set MemoVolume to NiveauVolume
  6. end
  7.  
  8. on StoreVolume
  9.   global MemoVolume
  10.   updateStage()
  11.   set MemoVolume to the soundLevel
  12. end
  13.  
  14. on RestoreVolume
  15.   global MemoVolume
  16.   set the soundLevel to MemoVolume
  17.   updateStage()
  18. end
  19.  
  20. on Cson Piste
  21.   if paramCount() <> 0 then
  22.     sound stop param(1)
  23.   else
  24.     sound stop 1
  25.     sound stop 2
  26.     sound stop 3
  27.     sound stop 4
  28.   end if
  29.   updateStage()
  30. end
  31.  
  32. on PlayClick Op
  33.   if soundBusy(1) then
  34.     exit
  35.   end if
  36.   PlaySound(1, "Puppet", "clic")
  37.   if paramCount() <> 0 then
  38.     updateStage()
  39.   end if
  40. end
  41.  
  42. on ClicPlusWait
  43.   if soundBusy(1) then
  44.     exit
  45.   end if
  46.   PlaySound(1, "Puppet", "clic")
  47.   updateStage()
  48.   WaitFinSon()
  49. end
  50.  
  51. on PlaySound Piste, type, Fichier, volumePiste
  52.   global glQTmemo, listFichSound, MemoVolume
  53.   TestPresenceQT()
  54.   if getAt(glQTmemo, 2) <> 0 then
  55.     if (the movieRate of sprite getAt(glQTmemo, 1) <> 0) and stringp(Fichier) and (Piste = 1) then
  56.       exit
  57.     end if
  58.   end if
  59.   set the soundLevel to MemoVolume
  60.   set Fichier to MakeSeparator(Fichier)
  61.   set PosRef to Piste * 2
  62.   setAt(listFichSound, PosRef + 1, MakeNomPropre(Fichier))
  63.   setAt(listFichSound, PosRef + 2, type)
  64.   if type = "PLAY" then
  65.     sound playFile Piste, Fichier
  66.   else
  67.     puppetSound(Fichier)
  68.   end if
  69.   if voidp(volumePiste) then
  70.     set volumePiste to 255
  71.   end if
  72.   set the volume of sound Piste to volumePiste
  73. end
  74.  
  75. on PlaySoundVide Piste, type, Fichier, volumePiste
  76.   if soundBusy(Piste) = 0 then
  77.     PlaySound(Piste, type, Fichier, volumePiste)
  78.   end if
  79. end
  80.  
  81. on PlaySoundTest Piste, type, Fichier, volumePiste
  82.   global listFichSound
  83.   if soundBusy(Piste) <> 0 then
  84.     if MakeNomPropre(Fichier) = getAt(listFichSound, (Piste * 2) + 1) then
  85.       exit
  86.     end if
  87.   end if
  88.   PlaySound(Piste, type, Fichier, volumePiste)
  89. end
  90.  
  91. on PlaySoundNotAgain Piste, type, Fichier, volumePiste
  92.   global listFichSound
  93.   if MakeNomPropre(Fichier) = getAt(listFichSound, (Piste * 2) + 1) then
  94.     exit
  95.   end if
  96.   PlaySound(Piste, type, Fichier, volumePiste)
  97. end
  98.  
  99. on SetSoundPara Piste, type, Fichier, volumePiste
  100.   global glQTmemo, listFichSound
  101.   TestPresenceQT()
  102.   if getAt(glQTmemo, 1) <> 0 then
  103.     if the movieRate of sprite getAt(glQTmemo, 1) <> 0 then
  104.       exit
  105.     end if
  106.   end if
  107.   set PosRef to Piste * 2
  108.   setAt(listFichSound, PosRef + 1, MakeNomPropre(Fichier))
  109.   setAt(listFichSound, PosRef + 2, type)
  110. end
  111.  
  112. on SetDcKeepSound
  113.   global listKeepSound
  114.   set listKeepSound to list()
  115. end
  116.  
  117. on KeepSound Piste, type, Fichier, volumePiste
  118.   global listKeepSound
  119.   updateStage()
  120.   set listKeepSound to list(Piste, type, Fichier, volumePiste)
  121.   GestKeepSound()
  122. end
  123.  
  124. on GestKeepSound
  125.   global listKeepSound
  126.   if listKeepSound = [] then
  127.     exit
  128.   end if
  129.   if soundBusy(getAt(listKeepSound, 1)) then
  130.     exit
  131.   end if
  132.   PlaySound(getAt(listKeepSound, 1), getAt(listKeepSound, 2), getAt(listKeepSound, 3), getAt(listKeepSound, 4))
  133. end
  134.  
  135. on DiaporamaOff
  136.   global listDiapo
  137.   if voidp(listDiapo) then
  138.     set listDiapo to list()
  139.   end if
  140.   if listDiapo = list() then
  141.     exit
  142.   end if
  143.   set ParaSup to getAt(listDiapo, count(listDiapo))
  144.   if offset("KDS", ParaSup) <> 0 then
  145.     set Piste to getAt(listDiapo, 5)
  146.     if getAt(listDiapo, 6) <> "Quick" then
  147.       Cson(Piste)
  148.     else
  149.       QTspriteEfface(Piste)
  150.     end if
  151.   end if
  152.   if offset("KDC", ParaSup) <> 0 then
  153.     set SprCast to getAt(listDiapo, 7)
  154.     puppetSprite(SprCast, 1)
  155.     set the castNum of sprite SprCast to -1
  156.     updateStage()
  157.     puppetSprite(SprCast, 0)
  158.   end if
  159.   set lastMacro to the last word in ParaSup
  160.   if offset("LM", lastMacro) <> 0 then
  161.     do(lastMacro)
  162.   end if
  163.   set listDiapo to list()
  164. end
  165.  
  166. on SetDiaporama Piste, type, NomFichier, volume, PisteCastnum, ParaSound, ParaPreload
  167.   global listDiapo, CastEfface
  168.   set listDiapo to list(8, CastEfface, 0, 0, Piste, type, PisteCastnum)
  169.   set Pz to 1
  170.   repeat with compt = 1 to (the number of words in ParaSound - 1) / 4
  171.     add(listDiapo, value(word Pz of ParaSound))
  172.     set NumCast to the number of cast word Pz + 1 of ParaSound
  173.     if (NumCast <> -1) and (ParaPreload = 1) then
  174.       preLoadCast(NumCast)
  175.       updateStage()
  176.     end if
  177.     add(listDiapo, NumCast)
  178.     add(listDiapo, word Pz + 2 of ParaSound)
  179.     set Pz to Pz + 4
  180.   end repeat
  181.   add(listDiapo, "FIN")
  182.   set ParaSup to "# "
  183.   if offset("KDC", ParaSound) <> 0 then
  184.     set ParaSup to ParaSup & "KDC "
  185.   end if
  186.   if offset("KDS", ParaSound) <> 0 then
  187.     set ParaSup to ParaSup & "KDS "
  188.   end if
  189.   set lastMacro to the last word in ParaSound
  190.   if offset("LM", lastMacro) <> 0 then
  191.     set ParaSup to ParaSup & lastMacro
  192.   end if
  193.   add(listDiapo, ParaSup)
  194.   set NumCast to getAt(listDiapo, 9)
  195.   if NumCast <> -1 then
  196.     preLoadCast(NumCast)
  197.     updateStage()
  198.   end if
  199.   puppetSprite(PisteCastnum, 1)
  200.   if type = "Quick" then
  201.     QTspriteStart([Piste, NomFichier, 0, 0, volume, 0, 1, 0, 1, 0, 1, 0, 0, 0])
  202.     QTspriteStartEndTime([Piste, 1, "Fin"])
  203.     QTspriteStart([Piste, #auto, 1, 1])
  204.     updateStage()
  205.     setAt(listDiapo, 3, 0)
  206.   else
  207.     if NomFichier <> "Nothing" then
  208.       PlaySound(Piste, type, NomFichier, volume)
  209.     end if
  210.     updateStage()
  211.     setAt(listDiapo, 3, the ticks)
  212.   end if
  213.   setAt(listDiapo, 4, getAt(listDiapo, 3) + getAt(listDiapo, 8))
  214.   GestSoundCast()
  215. end
  216.  
  217. on GestSoundCast
  218.   global listDiapo
  219.   if listDiapo = [] then
  220.     exit
  221.   end if
  222.   if getAt(listDiapo, 6) = "Quick" then
  223.     if getAt(listDiapo, 4) > the movieTime of sprite getAt(listDiapo, 5) then
  224.       exit
  225.     end if
  226.   else
  227.     if getAt(listDiapo, 4) > the ticks then
  228.       exit
  229.     end if
  230.   end if
  231.   set Compteur to getAt(listDiapo, 1)
  232.   set CastAAfficher to getAt(listDiapo, Compteur + 1)
  233.   set PisteSprite to getAt(listDiapo, 7)
  234.   set LastCast to getAt(listDiapo, 2)
  235.   do(getAt(listDiapo, Compteur + 2))
  236.   if CastAAfficher <> -1 then
  237.     set the castNum of sprite PisteSprite to CastAAfficher
  238.     updateStage()
  239.     unLoadCast(LastCast)
  240.     if listDiapo = list() then
  241.       exit
  242.     end if
  243.     setAt(listDiapo, 2, CastAAfficher)
  244.   end if
  245.   if listDiapo = [] then
  246.     exit
  247.   end if
  248.   set Compteur to Compteur + 3
  249.   setAt(listDiapo, 1, Compteur)
  250.   if getAt(listDiapo, Compteur) = "FIN" then
  251.     return DiaporamaOff()
  252.   end if
  253.   setAt(listDiapo, 4, getAt(listDiapo, 3) + getAt(listDiapo, Compteur))
  254. end
  255.  
  256. on SetDcSoundCast
  257.   DiaporamaOff()
  258. end
  259.  
  260. on SetSound type, NomSoundOuPisteQuick, PisteCastnum, ParaSound, NomCast
  261.   if type = "Quick" then
  262.     if the paramCount < 5 then
  263.       set NomCast to #auto
  264.     end if
  265.     SetDiaporama(NomSoundOuPisteQuick, type, NomCast, 255, PisteCastnum, ParaSound, 0)
  266.   else
  267.     SetDiaporama(1, type, NomSoundOuPisteQuick, 255, PisteCastnum, ParaSound, 0)
  268.   end if
  269. end
  270.